const glob = require('glob')
const { VueLoaderPlugin } = require('vue-loader')
const path = require('path')

const list = {}
function makedir(dirPath, list) {
  const files = glob.sync(`${dirPath}/**/index.js`)
  files.forEach(file => {
    list[file.split(/[/.]/)[2]] = path.resolve(__dirname, file)
  })
}
makedir('components/lib', list)

module.exports = {
  entry: list,
  mode: 'development',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].umd.js',
    library: 'zui',
    libraryTarget: 'umd'
  },
  plugins: [
    new VueLoaderPlugin()
  ],
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: [
          {
            loader: 'vue-loader'
          }
        ]
      }
    ]
  }
}